package com.gray.blog.common.enums;

public enum ErrorCodeEnum {

    // 系统相关(0 - 999)
    SUCCESS(0, "成功"),
    FAILURE(1, "失败"),
    SYSTEM_ERROR(2, "系统错误"),
    PARAMS_ERROR(3, "参数错误"),

    // 权限验证相关(1000 - 1500)
    IP_IS_DISABLED(1001,"该ip被禁用"),
    USER_NOT_LOGIN(1002, "用户未登录"),
    LOGIN_FAIL(1003, "登录失败"),
    USER_NO_PERMISSION(1004, "该用户无访问权限"),
    TOKEN_INVALID(1005, "登录状态失效"),
    TOKEN_NOT_FOUND(1006, "token不存在"),

    // 系统用户相关(1501 - 2000)
    SYS_USER_NOT_FOUND(1501, "该系统用户不存在"),


    // 游戏模块相关(2001 - 2500)
    GAME_INFO_NOT_EXIST(2001, "游戏数据不存在"),
    SYS_DELETE_GAME_ERROR(2002, "删除游戏数据失败"),


    // 极客模块相关(2501 - 3000)
    GEEK_INFO_NOT_EXIST(2501, "极客数据不存在")
    ;

    ErrorCodeEnum(int errorCode, String errorMessage) {
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    private int errorCode;
    private String errorMessage;

    public int getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public static ErrorCodeEnum getByCode(int code) {
        for (ErrorCodeEnum ErrorCodeEnum : values()) {
            if (ErrorCodeEnum.getErrorCode() == code) {
                return ErrorCodeEnum;
            }
        }
        return null;
    }
}
